from rest_framework import viewsets

from sqtp.models import Project, Environment
from sqtp.permissions import IsOwnerOrRedeOnly
from sqtp.serializers import ProjectSerializer, EnvironmentSerializer


class ProjectViewSet(viewsets.ModelViewSet):
    queryset = Project.objects.all()
    serializer_class = ProjectSerializer
    # 权限
    # authentication_classes = (SessionAuthentication, BasicAuthentication)
    permission_classes = [IsOwnerOrRedeOnly]


class EnvironmentViewSet(viewsets.ModelViewSet):
    queryset = Environment.objects.all()
    serializer_class = EnvironmentSerializer
